package ${package.Entity};

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.extension.activerecord.Model;
<#list table.importPackages as pkg>
import ${pkg};
</#list>
<#if swagger>
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
</#if>
<#if entityLombokModel>
import lombok.Data;
import lombok.EqualsAndHashCode;
<#if chainModel>
import lombok.experimental.Accessors;
</#if>
</#if>

/**
 * ${table.comment!}
 *
 * @author ${author}
 * @since ${date}
 */
<#if entityLombokModel>
@Data
@EqualsAndHashCode(callSuper = false)
<#if chainModel>
@Accessors(chain = true)
</#if>
</#if>
@TableName("${schemaName}${table.name}")
<#if swagger>
@ApiModel(value = "${entity}对象", description = "${table.comment!}")
</#if>
public class ${entity} extends Model<${entity}> {
<#if entitySerialVersionUID>

    private static final long serialVersionUID = 1L;
</#if>
<#-- ----------  BEGIN 字段循环遍历  ---------->
<#list table.fields as field>
<#if field.keyFlag>
<#assign keyPropertyName="${field.propertyName}"/>
</#if>

<#if field.comment!?length gt 0>
<#if swagger>
    @ApiModelProperty("${field.comment}")
<#else>
/**
* ${field.comment}
*/
</#if>
</#if>
<#if field.keyFlag>
<#-- 主键 -->
<#if field.keyIdentityFlag>
    @TableId(value = "${field.annotationColumnName}", type = IdType.AUTO)
<#elseif idType??>
    @TableId(value = "${field.annotationColumnName}", type = IdType.${idType})
<#elseif field.convert>
    @TableId("${field.annotationColumnName}")
</#if>
<#-- 普通字段 -->
<#elseif field.fill??>
<#-- -----   存在字段填充设置   ----->
<#if field.convert>
<#if "CREATE_NAME" == field.name || "create_name" == field.name>
    @TableField(value = "${field.name}", fill = FieldFill.${field.fill}, updateStrategy = FieldStrategy.NOT_NULL)
<#elseif "CREATE_TIME" == field.name || "create_time" == field.name>
    @TableField(value = "${field.name}", fill = FieldFill.${field.fill}, updateStrategy = FieldStrategy.NOT_NULL)
<#elseif "UPDATE_NAME" == field.name || "update_name" == field.name>
    @TableField(value = "${field.name}", fill = FieldFill.${field.fill}, updateStrategy = FieldStrategy.NOT_NULL)
<#elseif "UPDATE_TIME" == field.name || "update_time" == field.name>
    @TableField(value = "${field.name}", fill = FieldFill.${field.fill}, updateStrategy = FieldStrategy.NOT_NULL)
<#elseif "DEL" == field.name || "del" == field.name>
    @TableField(value = "${field.name}", fill = FieldFill.${field.fill}, updateStrategy = FieldStrategy.NOT_NULL)
<#else>
    @TableField(value = "${field.name}", fill = FieldFill.${field.fill})
</#if>
<#else>
<#if "CREATE_NAME" == field.name || "create_name" == field.name>
    @TableField( fill = FieldFill.${field.fill}, updateStrategy = FieldStrategy.NOT_NULL)
<#elseif "CREATE_TIME" == field.name || "create_time" == field.name>
    @TableField( fill = FieldFill.${field.fill}, updateStrategy = FieldStrategy.NOT_NULL)
<#elseif "UPDATE_NAME" == field.name || "update_name" == field.name>
    @TableField(fill = FieldFill.${field.fill}, updateStrategy = FieldStrategy.NOT_NULL)
<#elseif "UPDATE_TIME" == field.name || "update_time" == field.name>
    @TableField( fill = FieldFill.${field.fill}, updateStrategy = FieldStrategy.NOT_NULL)
<#elseif "DEL" == field.name || "del" == field.name>
    @TableField(fill = FieldFill.${field.fill}, updateStrategy = FieldStrategy.NOT_NULL)
<#else>
    @TableField(fill = FieldFill.${field.fill})
</#if>
</#if>
<#elseif field.convert>
<#if "CREATE_NAME" == field.name || "create_name" == field.name>
    @TableField(value = "${field.name}", updateStrategy = FieldStrategy.NOT_NULL)
<#elseif "CREATE_TIME" == field.name || "create_time" == field.name>
    @TableField(value = "${field.name}", updateStrategy = FieldStrategy.NOT_NULL)
<#elseif "UPDATE_NAME" == field.name || "update_name" == field.name>
    @TableField(value = "${field.name}", updateStrategy = FieldStrategy.NOT_NULL)
<#elseif "UPDATE_TIME" == field.name || "update_time" == field.name>
    @TableField(value = "${field.name}", updateStrategy = FieldStrategy.NOT_NULL)
<#elseif "DEL" == field.name || "del" == field.name>
    @TableField(value = "${field.name}", updateStrategy = FieldStrategy.NOT_NULL)
<#else>
    @TableField("${field.name}")
</#if>
</#if>
<#-- 乐观锁注解 -->
<#if field.versionField>
    @Version
</#if>
<#-- 逻辑删除注解 -->
<#if field.logicDeleteField>
    @TableLogic
</#if>
    private ${field.propertyType} ${field.propertyName};
</#list>
<#------------  END 字段循环遍历  ---------->

<#if !entityLombokModel>
<#list table.fields as field>
<#if field.propertyType == "boolean">
<#assign getprefix="is"/>
<#else>
<#assign getprefix="get"/>
</#if>
    public ${field.propertyType} ${getprefix}${field.capitalName}() {
        return ${field.propertyName};
    }

<#if chainModel>
    public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
<#else>
    public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
</#if>
        this.${field.propertyName} = ${field.propertyName};
<#if chainModel>
        return this;
</#if>
    }
</#list>
</#if>
<#if entityColumnConstant>
<#list table.fields as field>
    public static final String ${field.name?upper_case} = "${field.name}";
</#list>
</#if>
    @Override
    public Serializable pkVal() {
<#if keyPropertyName??>
        return this.${keyPropertyName};
<#else>
        return null;
</#if>
    }
<#if !entityLombokModel>
    @Override
    public String toString() {
        return "${entity}{" +
        <#list table.fields as field>
        <#if field_index==0>
        "${field.propertyName}=" + ${field.propertyName} +
        <#else>
        ", ${field.propertyName}=" + ${field.propertyName} +
        </#if>
        </#list>
        "}";
    }
</#if>
}
